package com.example.javapoint.keywords;

class Person {
    private String name;
    private int age;
    Person(String name, int age){
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

class Man extends Person {
    private String sex;
    Man(String name, int age, String sex) {
        super(name, age);
        this.sex = sex;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}

/**
 * java 关键字 super
 * 调用父类实例变量，父类的构造方法和普通方法
 * 子类构造方法实现时，如果没有加入父类的super(),在编译是编译器会默认给其加入super() 父类构造方法
 */
public class KeyWordsSuper {
    public static void main(String[] args) {
        Man man = new Man("jack", 56, "MAIL");
        System.out.println(man.getSex());
        System.out.println(man.getName());
    }
}
